package edu.ufl.cise.cop5555.sp12.ast;

import edu.ufl.cise.cop5555.sp12.Kind;

public class CompoundType extends Type {
	
	public final SimpleType keyType;
	public final Type valType;

	
	
public Kind getKeyKind()
{
	return keyType.getKind();
	
}
public Kind getValKind()
{
	return valType.getKind();
	
}
	
	public CompoundType(SimpleType keyType, Type valType) {
		this.keyType = keyType;
		this.valType = valType;
	}

	@Override
	public Object visit(ASTVisitor v, Object arg) throws Exception {
		return v.visitCompoundType(this, arg);
	}

	
	@Override
	public boolean equals(Object o) {
		if (!(o instanceof CompoundType))
			return false;
		CompoundType other = (CompoundType) o;
		try {
			return (keyType.equals(other.keyType) && valType.equals(other.valType))  ;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		
	}
	@Override
	public Kind getKind() {
		// TODO Auto-generated method stub
		if(valType instanceof CompoundType)
			return Kind.MAP;
		else
			return valType.getKind();
	}
}
